package my.thread;

public class ThreadMethod {

	int i = 1;

	public synchronized void calcNumber() {
		if (i != 0) {
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		i++;
		System.out.print(i);
		notify();
	}

	public synchronized void calcNumber2() {
		if (i != 1) {
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		i--;
		System.out.print(i);
		notify();
	}
}
